URL = "http://www.pyside.org/files/apiextractor-%(VERSION)s.tar.bz2"
VERSIONS = ["0.10.0", "0.10.1", "0.10.2", "0.10.3"]
DEFAULT_VERSION = "0.10.3"
DEPENDS = ["jom", "libxml2", "libxslt", "qt4osmin"]

from source.builders import CMakeJomBuilder
import os

class apiextractorBuilder( CMakeJomBuilder ):
  """ subclass of CMakeJomBuilder with custom configure step """

  def configure(self):
    if "jom" in self.dependencies.keys(): 
      self.dependencies["jom"].addexetopath()

    qtdir = self.dependencies['qt4osmin'].targetpath()
    os.environ['QTDIR'] = qtdir

    libxmldir= self.dependencies["libxml2"].targetpath()+os.sep
    xmlincdir = " -DLIBXML2_INCLUDE_DIR=" + libxmldir+"include"+("", os.sep+"libxml2")[self.machine.isLinux()]
    xmllib = " -DLIBXML2_LIBRARIES="+libxmldir+"lib"+os.sep+("libxml2.lib", "libxml2.so")[self.machine.isLinux()]
    xmllint = " -DLIBXML2_XMLLINT_EXECUTABLE="+libxmldir+"bin"+os.sep+("xmllint.exe", "xmllint")[self.machine.isLinux()]

    libxsltdir= self.dependencies["libxslt"].targetpath()+os.sep
    xsltincdir = " -DLIBXSLT_INCLUDE_DIR=" + libxsltdir+"include"
    xsltlib = " -DLIBXSLT_LIBRARIES="+libxsltdir+"lib"+os.sep+("libxslt.lib", "libxslt.so")[self.machine.isLinux()]

    debugpostfix = r" -DCMAKE_DEBUG_POSTFIX='_d'"

    CMakeJomBuilder.configure(self, xmlincdir+xmllib+xmllint+xsltincdir+xsltlib+debugpostfix)

BUILDER = apiextractorBuilder

